<template>
	<view class="bg">
		<view style="padding-top: 15px;">
			<view class="from">
				<uni-forms ref="baseForm" :rules="rules" :modelValue="form">
					<uni-row class="demo-uni-row" style="margin-top: 15px;">
						<uni-col :span="8">
							<uni-forms-item label-width="110px" :required="true" name="fkXc" label="问题分类:"
								class="input">
								<zxz-uni-data-select v-model="form.fkXc" :filterable="true" dataKey="dictName"
									dataValue="dictName" :localdata="questionClassificationPolish"
									@inputChange="handleInput4"@change="featureCode(form)"></zxz-uni-data-select>
							</uni-forms-item>
						</uni-col>
						<uni-col :span="8">
							<uni-forms-item label-width="110px" :required="true" name="chitStandardvaluePolish"
								label="标准值:" class="input">
								<uni-easyinput v-model="form.chitStandardvaluePolish" placeholder="请输入标准值" />
							</uni-forms-item>
						</uni-col>
						<uni-col :span="8">
							<uni-forms-item label-width="110px" :required="true" name="fkBzd" label="实测值:"
								class="input">
								<uni-easyinput v-model="form.fkBzd" placeholder="请输入实测值" />
							</uni-forms-item>
						</uni-col>
					</uni-row>
					<uni-row class="demo-uni-row">
						<uni-col :span="8">
							<uni-forms-item label-width="110px" label="超差值:" class="input">
								<uni-easyinput v-model="form.excessValue" placeholder="请输入超差值" />
							</uni-forms-item>
						</uni-col>
						<uni-col :span="8">
							<uni-forms-item label-width="110px" :required="true" name="featureClassification4"
								label="特征分类:" class="input">
								<zxz-uni-data-select v-model="form.featureClassification4" :filterable="true"
									dataKey="dictName" dataValue="dictCode" :localdata="featureClassificationList"
								@inputChange="handleInput2"	@change="changefeatureClassification"></zxz-uni-data-select>
							</uni-forms-item>
						</uni-col>
						<uni-col :span="8">
							<uni-forms-item label-width="110px" label="序列号/刻字号:" class="input">
								<uni-easyinput v-model="form.fkXlh" placeholder="请输入序列号/刻字号" />
							</uni-forms-item>
						</uni-col>
					</uni-row>
					<uni-row class="demo-uni-row">
						<uni-col :span="8">
							<uni-forms-item label-width="110px" :required="true" name="fkBls" label="不良数:"
								class="input">
								<uni-easyinput v-model="form.fkBls" placeholder="请输入不良数" />
							</uni-forms-item>
						</uni-col>
						<uni-col :span="8">
							<uni-forms-item label-width="110px" label="子件编码:" class="input">
								<zxz-uni-data-select v-model="form.childMateId" :filterable="true" dataKey="MATE_CODE"
									dataValue="MATE_ID" :localdata="bomMsgData" @inputChange="handleInput5"
									@change="handleChildMateidSelectChange"></zxz-uni-data-select>
							</uni-forms-item>
						</uni-col>
						<uni-col :span="8">
							<uni-forms-item label-width="110px" :required="true" name="equipment" label="作业班组:"
								class="input">
								<zxz-uni-data-select v-model="form.equipment" :filterable="true" dataKey="MANU_NAME"
								 @inputChange="handleInput1"	dataValue="MANU_NAME" :localdata="equipmentDic"></zxz-uni-data-select>
							</uni-forms-item>
						</uni-col>
					</uni-row>
					<uni-row class="demo-uni-row">
						<uni-col :span="8">
							<uni-forms-item label-width="110px" :required="true" name="processResourcesGroup"
								label="工艺资源组:" class="input">
								<zxz-uni-data-select v-model="form.processResourcesGroup" :filterable="true"
									dataKey="dictName" dataValue="dictCode"  @inputChange="handleInput3"	
									:localdata="processResourcesGroupDic"></zxz-uni-data-select>
							</uni-forms-item>
						</uni-col>
					</uni-row>
				</uni-forms>
			</view>
		</view>
		<uni-section title="上传图片" type="line" titleFontSize="20px" padding="0 0 0px 0px">
			<view class="uni-file-picker__container" style="margin-left: 2%;">
				<view class="file-picker__box" v-for="(item,index) in imageList" :key="index">
					<view class="file-picker__box-content">
						<image class="file-image" :src="item.url" mode="aspectFill"
							@click.stop="prviewImage(item,index)">
						</image>
						<view class="icon-del-box" @click.stop="delFile(index,item)">
							<view class="icon-del"></view>
							<view class="icon-del rotate"></view>
						</view>
					</view>
				</view>
				<view class="file-picker__box">
					<view class="file-picker__box-content is-add" @click="choose">
						<slot>
							<view class="icon-add"></view>
							<view class="icon-add rotate"></view>
						</slot>
					</view>
				</view>
			</view>
			<view style="height: 70px;margin-top: 1%;padding-bottom: 2%;">
				<button class="mini-btn " style="width: 50%; margin-left: 25%;" @click="submit('baseForm')"
					:loading="isLock" type="primary">保存</button>
			</view>
		</uni-section>
		<uni-popup ref="popup" background-color="#fff">
			<view style="width:35vh;height:18vh;/">
				<button type="primary" style="width:15vh; margin-top:2vh;" @click="photo">拍照</button>
				<button type="primary" style="width:15vh; margin-top:1vh;" @click="album">相册</button>
			</view>
		</uni-popup>
		<uni-popup ref="abnormalMangerHistory" type="dialog">
			<uni-popup-dialog style="width: 100%; height: 470px;" type="info" title="历史异常" :before-close="true"
				:showClose="false" confirmText="关闭" @confirm="abnormalMangerHistoryclose">
				<view style="width: 100%;">
					<uni-search-bar v-model="chitName" radius="4" cancelButton="always" cancel-text="查询"
						placeholder="问题分类" @cancel="abnormalMangerHistoryClick" />
					<uni-table ref="table" style="height: 250px;" :loading="Historyloading" border stripe
						emptyText="暂无更多数据">
						<uni-tr>
							<uni-th align="center">零件号</uni-th>
							<uni-th align="center">发现工序</uni-th>
							<uni-th align="center">问题分类</uni-th>
							<uni-th align="center">理论值/公差</uni-th>
							<uni-th align="center">异常现象</uni-th>
							<uni-th align="center">超差值</uni-th>
							<uni-th align="center">判定结果</uni-th>
							<uni-th align="center">操作</uni-th>
						</uni-tr>
						<uni-tr v-for="(item, index) in HistoryTable" :key="index">
							<uni-td>{{ item.partNumber }}</uni-td>
							<uni-td align="center">{{ item.jobCode }}</uni-td>
							<uni-td align="center">{{ item.chitName }}</uni-td>
							<uni-td align="center">{{ item.chitStandardvalue }}</uni-td>
							<uni-td align="center">{{ item.remark }}</uni-td>
							<uni-td align="center">{{ item.distanceValue }}</uni-td>
							<uni-td align="center">
								{{ item.decisionResult===1 ? '让步' : '' }}
								{{ item.decisionResult===2 ? '返修' : '' }}
								{{ item.decisionResult===3 ? '报废' : '' }}
							</uni-td>
							<uni-td align="center">
								<view class="uni-group">
									<button class="uni-button" size="mini" type="primary"
										@click="handleAddCallBack(item)">复制信息</button>
								</view>
							</uni-td>
						</uni-tr>
					</uni-table>
					<view class="uni-pagination-box">
						<uni-pagination show-icon :page-size="History.pageSize" :current="History.currentPage"
							:total="History.total" @change="Historyhange" />
					</view>
				</view>
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import config from '@/config'
	import {
		getToken
	} from '@/utils/auth'
	import {
		ResourceGroups,
		getDictData,
		listByCode,
		getJobBomMsgData,
		pageByParamGetHistoryAbnormalItem,
		pcpGetList,
		save,
		getPhoto,
		deleteFile,
	} from '@/api/system/fankui.js'
	export default {
		data() {
			return {
				fkId: "",
				type: "",
				isLock: false,
				imageList: [],
				rules: {
					fkXc: {
						rules: [{
							required: true,
							errorMessage: '问题分类不能为空'
						}]
					},
					chitStandardvaluePolish: {
						rules: [{
							required: true,
							errorMessage: '标准值不能为空'
						}]
					},
					fkBzd: {
						rules: [{
							required: true,
							errorMessage: '实测值不能为空'
						}]
					},
					featureClassification4: {
						rules: [{
							required: true,
							errorMessage: '特征分类不能为空'
						}]
					},
					fkBls: {
						rules: [{
							required: true,
							errorMessage: '不良数不能为空'
						}]
					},
					equipment: {
						rules: [{
							required: true,
							errorMessage: '作业班组不能为空'
						}]
					},
					processResourcesGroup: {
						rules: [{
							required: true,
							errorMessage: '工艺资源组不能为空'
						}]
					},
				},
				form: {
					fkXc: null,
					chitStandardvaluePolish: null,
					chitPositiveerror: null,
					chitNegativeerror: null,
					fkBzd: null,
					excessValue: null,
					descriptionSelect: null,
					descriptionSelectText: null,
					fkCcz: null,
					fkBls: null,
					fkXlh: null,
					zjfs: null,
					zjfsText: null,
					equipment: null,
					processResourcesGroup: null,
				},
				questionClassificationPolish: [],
				featureClassificationList: [],
				featureClassificationList01: [],
				featureClassificationList02: [],
				featureClassificationList03: [],
				processResourcesGroupDic: [],
				equipmentDic: [],
				pcpList: [],
				bomMsgData: [],
				abnormalMangerItemHistory: {
					jobIds: [],
					jobCode: null,
					version: null,
					partNumber: null,
					mateCode: null,
					chitName: null,
				},
				userInfo: {
					code: "",
					userName: "",
				},
				backInfo: {},
				jobId: "",
				// 历史异常分页
				History: {
					pageSize: 10,
					currentPage: 1,
					total: 0
				},
				// 历史异常
				chitName: "",
				// 历史异常 加载表格
				Historyloading: false,
				// 历史异常 表格数据
				HistoryTable: [],
				searchInput: "",
				filteredOptions: [],
			}
		},
		onLoad(options) {
			console.log(options)
			let data = JSON.parse(options.data);
			this.jobId = data.jobId;
			this.userInfo = data.userInfo;
			this.backInfo = data.backInfo;
			this.abnormalMangerItemHistory.jobIds = data.abnormalMangerItemHistory.jobIds;
			this.abnormalMangerItemHistory.jobCode = data.abnormalMangerItemHistory.jobCode;
			this.abnormalMangerItemHistory.version = data.abnormalMangerItemHistory.version;
			this.abnormalMangerItemHistory.partNumber = data.abnormalMangerItemHistory.partNumber;
			this.abnormalMangerItemHistory.mateCode = data.abnormalMangerItemHistory.mateCode;
			this.type = data.type;
			
			if (data.type === "add") {
				this.form = {}
				this.reset();
				this.form.equipment = data.formequipment;
				this.form.processResourcesGroup = data.formprocessResourcesGroup + "";
				//console.log(this.form.processResourcesGroup)
			} else if (data.type === "edit") {
				this.reset();
				this.fkId = data.fkId;
				this.form = data.form;
				this.selectPhoto(data.fkId, this.userInfo.userName, getToken());
			}
			this.pcpInit();
		},
		created() {
			this.init();
		},
		methods: {
			handleInput1(input) {
				this.searchInput = input;
				this.filterOptions1();
			},
			filterOptions1() {
				if (!this.searchInput) {
					this.filteredOptions = this.equipmentDic;
					return;
				}
				// 模糊检索逻辑
				const filterRegex = new RegExp(this.searchInput, 'i');
				this.filteredOptions = this.equipmentDic.filter(option => {
					return filterRegex.test(option.text);
				});
			},
			handleInput2(input) {
				this.searchInput = input;
				this.filterOptions2();
			},
			filterOptions2() {
				if (!this.searchInput) {
					this.filteredOptions = this.featureClassificationList;
					return;
				}
				// 模糊检索逻辑
				const filterRegex = new RegExp(this.searchInput, 'i');
				this.filteredOptions = this.featureClassificationList.filter(option => {
					return filterRegex.test(option.text);
				});
			},
			handleInput3(input) {
				this.searchInput = input;
				this.filterOptions3();
			},
			filterOptions3() {
				if (!this.searchInput) {
					this.filteredOptions = this.processResourcesGroupDic;
					return;
				}
				// 模糊检索逻辑
				const filterRegex = new RegExp(this.searchInput, 'i');
				this.filteredOptions = this.processResourcesGroupDic.filter(option => {
					return filterRegex.test(option.text);
				});
			},
			handleInput4(input) {
				this.searchInput = input;
				this.filterOptions4();
			},
			filterOptions4() {
				if (!this.searchInput) {
					this.filteredOptions = this.questionClassificationPolish;
					return;
				}
				// 模糊检索逻辑
				const filterRegex = new RegExp(this.searchInput, 'i');
				this.filteredOptions = this.questionClassificationPolish.filter(option => {
					return filterRegex.test(option.text);
				});
			},
			handleInput5(input) {
				this.searchInput = input;
				this.filterOptions5();
			},
			filterOptions5() {
				if (!this.searchInput) {
					this.filteredOptions = this.bomMsgData;
					return;
				}
				// 模糊检索逻辑
				const filterRegex = new RegExp(this.searchInput, 'i');
				this.filteredOptions = this.bomMsgData.filter(option => {
					return filterRegex.test(option.text);
				});
			},
			selectPhoto(dataId, uploader, Authorization) {
				getPhoto(dataId, uploader, Authorization).then(res => {
					if (res.code === 200) {
						let files = res.data;
						for (var i = 0; i < files.length; i++) {
							this.imageList.push({
								url: files[i].fileUrl,
								type: 2,
								fileId: files[i].fileId,
							})
						}
					} else {
						this.$modal.msgError("读取图片失败")
					}
				});
			},
			init() {
				// 工艺资源组
				ResourceGroups("", "").then(res => {
					this.equipmentDic = res.data
				});
				//工艺资源组  /system/v9/dictionary/listByCode?dictCode=QUALITY.PROCESS_RESOURCES_GROUP
				getDictData('QUALITY.PROCESS_RESOURCES_GROUP').then(response => {
					this.processResourcesGroupDic = response.data;
					//console.log(this.processResourcesGroupDic)
				});
				//问题分类
				listByCode('QUALITY.QUESTION_CLASSIFICATION_POLISH').then(res => {
					let data = res.data
					this.questionClassificationPolish = data;
				})
				// 特征分类
				listByCode('featureClassification').then(res => {
					let data = res.data
					let allList = this.getAllNode(data, 0, 0, [])
					this.featureClassificationList = allList.filter(i => i['node'] == 4)
					this.featureClassificationList03 = allList.filter(i => i['node'] == 3);
					this.featureClassificationList02 = allList.filter(i => i['node'] == 2);
					this.featureClassificationList01 = allList.filter(i => i['node'] == 1);
				})
			},
			pcpInit() {
				pcpGetList(this.jobId).then((res) => {
					this.pcpList = res.data;
					let pcpSolid = [];
					let userInfo = this.userInfo;
					this.pcpList.push({
						// 检验项
						FeatureCode: "",
						// 标准值
						chitStandardvaluePolish: "",
						// 正误差
						chitPositiveerror: "",
						// 负误差
						chitNegativeerror: "",
						//操作员
						czy: userInfo.userName,
						//设备标号型号
						sbbh: this.equiCode,
					})
					this.pcpList = this.pcpList.concat(pcpSolid);
					this.pcpList.sort((a, b) => {
						if (a.FeatureCode === "") {
							return -1;
						} else if (b.FeatureCode === "") {
							return 1;
						} else {
							return 0;
						}
					})
				});
				// 拉取BOM信息
				getJobBomMsgData(this.jobId).then(response => {
					this.bomMsgData = response.data
				});
			},
			//对数字字典进行分级处理
			getAllNode(data, pid, node, list) {
				if (data == null) {
					return [];
				}
				data.forEach((item) => {
					item["node"] = node + 1
					item["pid"] = pid
					list.push(item)
					if (item.children != null) {
						this.getAllNode(item.children, item.dictId, item["node"], list)
					}
				})
				return list;
			},
			delFile(indexs, item) {
				if (item.type === 1) {
					uni.showModal({
						title: '删除图片',
						content: '是否删除当前图片？',
						success: (res) => {
							if (res.confirm) {
								var file = this.imageList;
								this.imageList = file.filter(function(value, index) {
									return index !== indexs; // 返回下标不为2的元素组成的新数组
								});
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});

				} else {
					uni.showModal({
						title: '删除图片',
						content: '是否删除当前图片？',
						success: (res) => {
							if (res.confirm) {
								deleteFile(item.fileId).then(response => {
									if (response.code === 200) {
										var file = this.imageList;
										this.imageList = file.filter(function(value, index) {
											return index !== indexs; // 返回下标不为2的元素组成的新数组
										});
									}
								});
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
				}
			},
			choose() {
				this.$refs.popup.open();
			},
			photo() {
				this.$refs.popup.close();
				var camera = plus.camera.getCamera() // 获取camera对象
				var resolution = camera.supportedImageResolutions // 获取字符串数组，摄像头支持的摄像分辨率
				camera.captureImage((res) => {
					// console.log(res)
					this.imageList.push({
						url: res,
						type: 1
					})
					// console.log(this.imageList)
				}, (error) => {
					this.$modal.msgError(error)
					// console.log()
				}, {
					resolution: resolution[resolution.length - 1],
					format: "jpg"
				})
			},
			album() {
				var that = this;
				this.$refs.popup.close();
				uni.chooseImage({
					count: 1000, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// console.log(JSON.stringify(res.tempFilePaths))
						for (var i = 0; i < res.tempFilePaths.length; i++) {
							that.imageList.push({
								url: res.tempFilePaths[i],
								type: 1
							});
						}
					}
				});
			},
			prviewImage(img, index) {
				let urls = []
				if (this.disablePreview) return
				this.imageList.forEach(i => {
					urls.push(i.url)
				})
				uni.previewImage({
					urls: urls,
					current: index
				});
			},
			featureCode(row) {
				//console.log(this.pcpList,row)
				let msg = {};
				this.pcpList.filter(x => x.chitName == row.fkXc).forEach(x => {
					msg = JSON.parse(JSON.stringify(x));
				})
				row.chitValuetype = msg.chitValueType;
				row.chitPositiveerror = msg.chitPositiveError;
				row.chitNegativeerror = msg.chitNegativeError;
				row.chitStandardvaluePolish = msg.chitStandardvaluePolish;
				this.abnormalMangerItemHistory.chitName = row.fkXc;
				this.chitName = row.fkXc;
				this.abnormalMangerItemHistory.callBackParam = row;
				this.abnormalMangerHistoryClick();
			},
			changefeatureClassification() {
				let node = 4
				if (this.form.featureClassification4) {
					this.featureClassificationList.filter(f => f.dictCode == this.form.featureClassification4).forEach(
						f => {
							this.form.featureClassificationName4 = f.dictName;
							this.featureClassificationList03.filter(f1 => f.pid == f1.dictId).forEach(f1 => {
								node = node - 1
								this.form.featureClassification3 = f1.dictCode
								this.form.featureClassificationName3 = f1.dictName;
								this.featureClassificationList02.filter(f2 => f1.pid == f2.dictId).forEach(
									f2 => {
										node = node - 1
										this.form.featureClassification2 = f2.dictCode
										this.form.featureClassificationName2 = f2.dictName;

										this.featureClassificationList01.filter(f3 => f2.pid == f3.dictId)
											.forEach(f3 => {
												node = node - 1
												this.form.featureClassification1 = f3.dictCode
												this.form.featureClassificationName1 = f3.dictName;
												if (node > 1) {
													this.changefeatureClassification()
												}

											})
									})
							})
						})
				} else {
					for (let i = 1; i <= node; i++) {
						this.form['featureClassification' + i] = '';
						this.form['featureClassificationName' + i] = '';
					}

				}
			},
			handleChildMateidSelectChange(value) {
				this.bomMsgData.filter(x => x.MATE_ID === value.childMateId).forEach(x => {
					this.form.childMateCode = x.MATE_CODE;
				})
			},
			// 表单重置
			reset() {
				this.form = {
					pcFeedbackId: this.backInfo.id,
					czyCode: this.userInfo.userCode,
					chitStandardvaluePolish: null,
					featureClassification4: null,
					chitPositiveerror: null,
					chitNegativeerror: null,
					descriptionSelect: null,
					excessValue: null,
					fkId: null,
					fkXc: null,
					fkBzd: null,
					DescriptionSelect: null,
					// 实测描述
					fkCcz: null,
					fkBls: null,
					fkXlh: null,
					zjfs: null,
					shebei: null,
					zjfsText: null,
					processResourcesGroup: null,
					processResourcesGroupText: null,
					DescriptionSelectText: null,
					equipment: null,
				};
				// this.resetForm("form");
			},
			// 历史异常
			abnormalMangerHistoryClick() {
				this.$refs.abnormalMangerHistory.open();
				this.Historyloading = true;
				let data = {
					chitName: this.chitName,
					decisionResult: "",
					handleAbnormal: "",
					isPage: 0,
					jobCode: this.abnormalMangerItemHistory.jobCode,
					jobMo: "",
					jobPos: "",
					mateCode: this.abnormalMangerItemHistory.mateCode,
					moIds: [],
					mos: [],
					pageIndex: this.History.currentPage,
					pageSize: this.History.pageSize,
					partNumber: "",
					projectInterventionJudge: "",
					version: null,
				}
				console.log(data)
				pageByParamGetHistoryAbnormalItem(data).then(res => {
					this.HistoryTable = res.data.records
					this.History.total = res.data.total
					this.Historyloading = false;
				})
			},
			// 历史异常关闭
			abnormalMangerHistoryclose() {
				this.$refs.abnormalMangerHistory.close();
			},
			// 历史异常翻页
			Historyhange(e) {
				this.History.currentPage = e.current;
				this.abnormalMangerHistoryClick();
			},
			// 历史异常复制
			handleAddCallBack(msg) {
				this.form.fkXc = msg.chitName;
				this.form.fkBzd = msg.inspectionValue;
				this.form.chitStandardvaluePolish = msg.chitStandardvalue;
				this.form.featureClassification4 = msg.featureClassification4;
				this.form.descriptionSelect = null;
				this.form.descriptionSelectText = null;
				this.form.fkCcz = msg.remark;
				this.form.fkBls = null;
				this.form.fkXlh = null; // 刻字号
				this.form.zjfs = null;
				this.form.zjfsText = msg.clampingMode;
				this.form.equipment = this.form.equipmentCode;
				this.form.processResourcesGroup = this.form.processResourcesGroup;
				this.form.abnormalMangerItemHistoryId = msg.id;
				this.form.pcFeedbackId = this.backInfo.id;
				this.$refs.abnormalMangerHistory.close();
				// this.fkBzdBlur();
				this.changefeatureClassification();
			},
			submit(ref) {
				this.isLock = true;
				this.$refs[ref].validate().then(res => {
					if (this.type === "add") {
						if (this.fkId === "") {
							this.form.submatState = 'NEW';
							save(this.form).then(response => {
								if (response.code === 200) {
									this.fkId = response.data.fkId;
									this.upload(response.data.fkId);
								} else {
									this.$modal.msgError("保存数据失败")
									this.isLock = false;
								}
							});
						} else {
							this.upload(this.fkId);
						}
					} else if (this.type === "edit") {
						save(this.form).then(response => {
							if (response.code === 200) {
								this.upload(this.form.fkId);
							} else {
								this.$modal.msgError("修改数据失败")
								this.isLock = false;
							}
						});
					} else {
						this.$modal.msgError("异常，返回上页")
					}
				}).catch(err => {
					this.$modal.msgSuccess("校验失败");
				})
			},
			// 上传图片
			upload(taskId) {
				const baseUrl = config.baseUrl;
				let files = [];
				let that = this;
				for (var i = 0; i < this.imageList.length; i++) {
					if(this.imageList[i].type===1){
						const path = this.imageList[i].url;
						const splitArray = path.split("/");
						const substring = splitArray[splitArray.length - 1];
						files.push({
							"name": substring,
							"uri": this.imageList[i].url,
						})
					}
				}
				console.log(files);
				if(files.length>0){
					const uploadTask = uni.uploadFile({
						url: baseUrl + '/quality/v9/BomFeedbackInfoItem/uploadList', //仅为示例，非真实的接口地址
						files: files,
						//name: 'file',
						formData: {
							dataId: taskId,
						},
						header: {
							'Authorization': getToken()
						},
						success: (uploadFileRes) => {
							console.log(uploadFileRes);
							if (JSON.parse(uploadFileRes.data).code == 200) {
								this.isLock = false;
								this.$modal.msgSuccess("保存成功");
								setTimeout(function() {
									uni.navigateBack({
										delta: 1 // 返回的页面数，这里设置为1表示返回上一页
									});
								}, 1000);
							} else {
								this.isLock = false;
								this.$modal.msgError("保存图片失败");
							}
						},
						fail: (uploadFileRes) => {
							this.isLock = false;
							this.$modal.msgError("保存图片失败");
						},
					});
					uploadTask.onProgressUpdate((res) => {
						console.log('上传进度' + res.progress);
						console.log('已经上传的数据长度' + res.totalBytesSent);
						console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
					});
				}else{
					this.isLock = false;
					this.$modal.msgSuccess("保存成功");
					setTimeout(function() {
						uni.navigateBack({
							delta: 1 // 返回的页面数，这里设置为1表示返回上一页
						});
					}, 1000);
				}
		
			}
		}
	}
</script>

<style scoped>
	.bg {
		margin-top: 0.1vh;
		height: 99.9vh;
		background-color: #fff;
	}

	.uni-file-picker {
		/* #ifndef APP-NVUE */
		box-sizing: border-box;
		overflow: hidden;
		width: 100%;
		/* #endif */
		flex: 1;
	}

	.uni-file-picker__container {
		/* #ifndef APP-NVUE */
		display: flex;
		box-sizing: border-box;
		/* #endif */
		flex-wrap: wrap;
		margin: -5px;

	}

	.file-picker__box {
		background-color: #fafafa;
		position: relative;
		/* 	// flex: 0 0 33.3%; */
		width: 15%;
		padding-top: 15%;
		/* #ifndef APP-NVUE */
		box-sizing: border-box;
		/* #endif */
	}

	.uni-file-picker__container {
		/* #ifndef APP-NVUE */
		display: flex;
		box-sizing: border-box;
		/* #endif */
		flex-wrap: wrap;
		margin: -5px;
	}

	.file-picker__box-content {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		margin: 5px;
		border: 1px #eee solid;
		border-radius: 5px;
		overflow: hidden;
	}

	.file-picker__progress {
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		/* border: 1px red solid; */
		z-index: 2;
	}

	.file-picker__progress-item {
		width: 100%;
	}

	.file-picker__mask {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
		position: absolute;
		right: 0;
		top: 0;
		bottom: 0;
		left: 0;
		color: #fff;
		font-size: 12px;
		background-color: #fff;
	}

	.file-image {
		width: 100%;
		height: 100%;
	}

	.is-add {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		align-items: center;
		justify-content: center;
	}

	.icon-add {
		width: 50px;
		height: 5px;
		background-color: #f1f1f1;
		border-radius: 2px;
	}

	.rotate {
		position: absolute;
		transform: rotate(90deg);
	}

	.icon-del-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 3px;
		right: 3px;
		height: 26px;
		width: 26px;
		border-radius: 50%;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 2;
		transform: rotate(-45deg);
	}

	.icon-del {
		width: 15px;
		height: 2px;
		background-color: #fff;
		border-radius: 2px;
	}

	.input {
		width: 95%;
		margin-right: 2%;
		margin-left: 3%;
	}

	.from {
		margin: 0px 15px 0px 15px;
		border: 1px #dbdbdb solid;
		border-radius: 5px;
	}
</style>